<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>验证码验证</title>
    <script src="jquery-3.6.0.min.js"></script>
</head>
<body>
    <img id="DriverDigit" src="" alt="验证码图片">
    <input type="text" id="DriverDigitInput" placeholder="请输入验证码">
    <button onclick="DriverDigit()">验证</button>
	<p>&nbsp</p>
	<p>&nbsp</p>
    <img id="DriverMath" src="" alt="验证码图片">
    <input type="text" id="DriverMathInput" placeholder="请输入验证码">
    <button onclick="DriverMath()">验证</button>
    
	<p>&nbsp</p>
	<p>&nbsp</p>
    <img id="DriverString" src="" alt="验证码图片">
    <input type="text" id="DriverStringInput" placeholder="请输入验证码">
    <button onclick="DriverString()">验证</button>
	
    <script>
	//处理数学公式验证码
	    var DriverMathID;
		function DriverMath() {
            var userInput = document.getElementById('DriverMathInput').value;
            $.post('/postDriverMath', { userInput: userInput,DriverMathID: DriverMathID}, function(data) { 
				alert(data);
				location.reload()
			});
        }
        $(document).ready(function() {
            $.get('/getDriverMath', function(data) {
                var base64Image = data.captchaImage;
				DriverMathID = data.DriverMathID;
                $('#DriverMath').attr('src', base64Image);
            });
        });

		//处理文本验证码
	   var DriverStringID;
		function DriverString() {
            var userInput = document.getElementById('DriverStringInput').value;
            $.post('/postDriverString', { userInput: userInput,DriverStringID: DriverStringID}, function(data) { 
				alert(data);
				location.reload()
			});
        }
        $(document).ready(function() {
            $.get('/getDriverString', function(data) {
                var base64Image = data.captchaImage;
				DriverStringID = data.DriverStringID;
                $('#DriverString').attr('src', base64Image);
            });
        });
		//处理数字验证码
        var DriverDigitID;
		function DriverDigit() {
            var userInput = document.getElementById('DriverDigitInput').value;
            $.post('/postDriverDigit', { userInput: userInput,DriverDigitID: DriverDigitID}, function(data) { 
				alert(data);
				location.reload()
			});
        }
        $(document).ready(function() {
            $.get('/getDriverDigit', function(data) {
                var base64Image = data.captchaImage;
				DriverDigitID = data.DriverDigitID;
                $('#DriverDigit').attr('src', base64Image);
            });
        });
    </script>
</body>
</html>
